@extends('admin.main_table')
@section('title', '管理员管理')

@section('css')
    <link href="{{ asset('/static/css/admin/admin.css') }}" rel="stylesheet">
    <style>
        .pagination-detail {
            margin-left: 20px;
        }

        .pagination {
            margin-right: 20px;
        }
    </style>
@endsection

@section('content')
    <div class="col-md-12 main_body">
        <div style="margin-bottom:10px;">
            <button class="btn btn-default" type="button" id="add"><img src="{{ asset('/static/img/新增.png') }}"
                                                                        style="width:18px;height:18px;"/>&nbsp;新增
            </button>
            <button class="btn btn-default" type="button" id="delete"><img src="{{ asset('/static/img/删除.png') }}"
                                                                           style="width:18px;height:18px;"/>&nbsp;删除
            </button>
            <button class="btn btn-default" type="button" id="change"><img src="{{ asset('/static/img/修改.png') }}"
                                                                           style="width:18px;height:18px;"/>&nbsp;修改
            </button>
        </div>

        <table data-toggle="table" id="article_table"></table>
    </div>
@endsection

@section('script')
    <script>
        $(function () {
            $(".sleep_nav").addClass('active');
            $(".sleep_nav").find(".nav-second-level").addClass('in');
            $($(".nav-second-level").children("li").get(1)).addClass('active');
        });

        function initTable() {
            var $table = $('#article_table');
            $table.bootstrapTable({
                pagination: true, //分页
                url: '/admin/getAllArticleType',
                pageList: [15, 30, 50],
                columns: [{
                    checkbox: true
                }, {
                    field: 'id',
                    title: '文章类型id'
                }, {
                    field: 'Number',
                    title: 'id',
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                }, {
                    field: 'name',
                    title: '类型名称'
                }]
            });
            $table.bootstrapTable('hideColumn', 'id');
        }

        initTable();

        $("#add").click(function () {
            window.location = "/addArticleType";
        });
        $('#delete').click(function () {
            var row = $('#article_table').bootstrapTable('getSelections');
            $.post('/deleteArticleType', {'row': row}, function (data) {
                window.location = "/articleTypeManage";
            })
        });
        $("#change").click(function () {
            var row = $('#article_table').bootstrapTable('getSelections');
            var id = row[0].id;
            //alert(id)
            //console.log(id);
            window.location = "/updateArticleType?id=" + id;
        });
    </script>

@endsection